package argo.hot100.greedy;

public class CanJump {

    public boolean canJump(int[] nums) {
        int longest = 0;
        for (int i = 0; i < nums.length; i++) {
            if (i <= longest) {
                longest = Math.max(longest, i + nums[i]);
                if (longest >= nums.length - 1) {
                    return true;
                }
            }
        }

        return false;
    }
}
